<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>Theron: Theron::DefaultAllocator Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Theron
   &#160;<span id="projectnumber">6.00.02</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceTheron.html">Theron</a></li><li class="navelem"><a class="el" href="classTheron_1_1DefaultAllocator.html">DefaultAllocator</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-attribs">Static Public Attributes</a> &#124;
<a href="classTheron_1_1DefaultAllocator-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Theron::DefaultAllocator Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>A simple general purpose memory allocator used by default.  
 <a href="classTheron_1_1DefaultAllocator.html#details">More...</a></p>

<p><code>#include &lt;DefaultAllocator.h&gt;</code></p>
<div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-0-trigger" src="closed.png" alt="+"/> Inheritance diagram for Theron::DefaultAllocator:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
 <div class="center">
  <img src="classTheron_1_1DefaultAllocator.png" usemap="#Theron::DefaultAllocator_map" alt=""/>
  <map id="Theron::DefaultAllocator_map" name="Theron::DefaultAllocator_map">
<area href="classTheron_1_1IAllocator.html" title="Interface describing a general-purpose memory allocator. " alt="Theron::IAllocator" shape="rect" coords="0,0,149,24"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:ab4f937fc8550c316305fc830ad779974"><td class="memItemLeft" align="right" valign="top">typedef <a class="el" href="namespaceTheron_a254da7d1d07833b997828500fbf73daa.html#a254da7d1d07833b997828500fbf73daa">uint32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1IAllocator_ab4f937fc8550c316305fc830ad779974.html#ab4f937fc8550c316305fc830ad779974">SizeType</a></td></tr>
<tr class="memdesc:ab4f937fc8550c316305fc830ad779974"><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines an integer type used for specifying sizes of memory allocations.  <a href="#ab4f937fc8550c316305fc830ad779974">More...</a><br/></td></tr>
<tr class="separator:ab4f937fc8550c316305fc830ad779974"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ad0f15268d1f4f5bef6287560d0aab262"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1DefaultAllocator_ad0f15268d1f4f5bef6287560d0aab262.html#ad0f15268d1f4f5bef6287560d0aab262">DefaultAllocator</a> ()</td></tr>
<tr class="memdesc:ad0f15268d1f4f5bef6287560d0aab262"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default constructor.  <a href="#ad0f15268d1f4f5bef6287560d0aab262">More...</a><br/></td></tr>
<tr class="separator:ad0f15268d1f4f5bef6287560d0aab262"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afda3ddc78b12ed2ad1df5a5c12c26be7"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1DefaultAllocator_afda3ddc78b12ed2ad1df5a5c12c26be7.html#afda3ddc78b12ed2ad1df5a5c12c26be7">~DefaultAllocator</a> ()</td></tr>
<tr class="memdesc:afda3ddc78b12ed2ad1df5a5c12c26be7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Virtual destructor.  <a href="#afda3ddc78b12ed2ad1df5a5c12c26be7">More...</a><br/></td></tr>
<tr class="separator:afda3ddc78b12ed2ad1df5a5c12c26be7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa48cb1758a7f85de84b15047484dfb08"><td class="memItemLeft" align="right" valign="top">virtual void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1DefaultAllocator_aa48cb1758a7f85de84b15047484dfb08.html#aa48cb1758a7f85de84b15047484dfb08">Allocate</a> (const <a class="el" href="classTheron_1_1IAllocator_ab4f937fc8550c316305fc830ad779974.html#ab4f937fc8550c316305fc830ad779974">SizeType</a> size)</td></tr>
<tr class="memdesc:aa48cb1758a7f85de84b15047484dfb08"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocates a block of contiguous memory.  <a href="#aa48cb1758a7f85de84b15047484dfb08">More...</a><br/></td></tr>
<tr class="separator:aa48cb1758a7f85de84b15047484dfb08"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad649f26a87a1e43c0cf539b5914a974a"><td class="memItemLeft" align="right" valign="top">virtual void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1DefaultAllocator_ad649f26a87a1e43c0cf539b5914a974a.html#ad649f26a87a1e43c0cf539b5914a974a">AllocateAligned</a> (const <a class="el" href="classTheron_1_1IAllocator_ab4f937fc8550c316305fc830ad779974.html#ab4f937fc8550c316305fc830ad779974">SizeType</a> size, const <a class="el" href="classTheron_1_1IAllocator_ab4f937fc8550c316305fc830ad779974.html#ab4f937fc8550c316305fc830ad779974">SizeType</a> alignment)</td></tr>
<tr class="memdesc:ad649f26a87a1e43c0cf539b5914a974a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocates a block of contiguous memory aligned to a given byte-multiple boundary.  <a href="#ad649f26a87a1e43c0cf539b5914a974a">More...</a><br/></td></tr>
<tr class="separator:ad649f26a87a1e43c0cf539b5914a974a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af0dab9d5e8c021d3eaf60bbfcbdcb0d9"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1DefaultAllocator_af0dab9d5e8c021d3eaf60bbfcbdcb0d9.html#af0dab9d5e8c021d3eaf60bbfcbdcb0d9">Free</a> (void *const memory)</td></tr>
<tr class="memdesc:af0dab9d5e8c021d3eaf60bbfcbdcb0d9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees a previously allocated block of contiguous memory.  <a href="#af0dab9d5e8c021d3eaf60bbfcbdcb0d9">More...</a><br/></td></tr>
<tr class="separator:af0dab9d5e8c021d3eaf60bbfcbdcb0d9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a368812ccfd6bf1780a9b74360b239826"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespaceTheron_a254da7d1d07833b997828500fbf73daa.html#a254da7d1d07833b997828500fbf73daa">uint32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1DefaultAllocator_a368812ccfd6bf1780a9b74360b239826.html#a368812ccfd6bf1780a9b74360b239826">GetBytesAllocated</a> () const </td></tr>
<tr class="memdesc:a368812ccfd6bf1780a9b74360b239826"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the number of bytes currently allocated by the allocator.  <a href="#a368812ccfd6bf1780a9b74360b239826">More...</a><br/></td></tr>
<tr class="separator:a368812ccfd6bf1780a9b74360b239826"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a42b6356c075558e513648eae05df21cb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespaceTheron_a254da7d1d07833b997828500fbf73daa.html#a254da7d1d07833b997828500fbf73daa">uint32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1DefaultAllocator_a42b6356c075558e513648eae05df21cb.html#a42b6356c075558e513648eae05df21cb">GetPeakBytesAllocated</a> () const </td></tr>
<tr class="memdesc:a42b6356c075558e513648eae05df21cb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the peak number of bytes ever allocated by the allocator at one time.  <a href="#a42b6356c075558e513648eae05df21cb">More...</a><br/></td></tr>
<tr class="separator:a42b6356c075558e513648eae05df21cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7aa1fb21aa04f2924e30d4eda10e2c43"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespaceTheron_a254da7d1d07833b997828500fbf73daa.html#a254da7d1d07833b997828500fbf73daa">uint32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1DefaultAllocator_a7aa1fb21aa04f2924e30d4eda10e2c43.html#a7aa1fb21aa04f2924e30d4eda10e2c43">GetAllocationCount</a> () const </td></tr>
<tr class="memdesc:a7aa1fb21aa04f2924e30d4eda10e2c43"><td class="mdescLeft">&#160;</td><td class="mdescRight">Gets the number of distinct allocations performed by the allocator.  <a href="#a7aa1fb21aa04f2924e30d4eda10e2c43">More...</a><br/></td></tr>
<tr class="separator:a7aa1fb21aa04f2924e30d4eda10e2c43"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a55ab415ea21b84226c1211f583477a00"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1IAllocator_a55ab415ea21b84226c1211f583477a00.html#a55ab415ea21b84226c1211f583477a00">Free</a> (void *const memory, const <a class="el" href="classTheron_1_1IAllocator_ab4f937fc8550c316305fc830ad779974.html#ab4f937fc8550c316305fc830ad779974">SizeType</a>)</td></tr>
<tr class="memdesc:a55ab415ea21b84226c1211f583477a00"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees a previously allocated block of contiguous memory of a known size.  <a href="#a55ab415ea21b84226c1211f583477a00">More...</a><br/></td></tr>
<tr class="separator:a55ab415ea21b84226c1211f583477a00"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-attribs"></a>
Static Public Attributes</h2></td></tr>
<tr class="memitem:a9ad5a3063a263e545f3a3c04189b0074"><td class="memItemLeft" align="right" valign="top">static const <a class="el" href="namespaceTheron_a254da7d1d07833b997828500fbf73daa.html#a254da7d1d07833b997828500fbf73daa">uint32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classTheron_1_1DefaultAllocator_a9ad5a3063a263e545f3a3c04189b0074.html#a9ad5a3063a263e545f3a3c04189b0074">GUARD_VALUE</a> = 0xdddddddd</td></tr>
<tr class="separator:a9ad5a3063a263e545f3a3c04189b0074"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A simple general purpose memory allocator used by default. </p>
<p>This is the allocator implementation used by default within <a class="el" href="namespaceTheron.html" title="Main namespace containing all public API components. ">Theron</a>. It extends the native C++ new and delete with support for aligned allocations, allocation counting, and guardband checking.</p>
<p>The <a class="el" href="classTheron_1_1DefaultAllocator.html" title="A simple general purpose memory allocator used by default. ">DefaultAllocator</a> is used by <a class="el" href="namespaceTheron.html" title="Main namespace containing all public API components. ">Theron</a> for its internal allocations, unless it is replaced by a custom allocator via <a class="el" href="classTheron_1_1AllocatorManager_a9ecdc8b1ae227f95a1eae7a2d399a9c0.html#a9ecdc8b1ae227f95a1eae7a2d399a9c0">AllocatorManager::SetAllocator</a>. The <a class="el" href="classTheron_1_1DefaultAllocator.html" title="A simple general purpose memory allocator used by default. ">DefaultAllocator</a> may also be used for allocations within user application code, if desired, in which case it can be accessed via <a class="el" href="classTheron_1_1AllocatorManager_ae9038770699e0ff14c0dd68378e8ad90.html#ae9038770699e0ff14c0dd68378e8ad90">AllocatorManager::GetAllocator</a>.</p>
<p>The <a class="el" href="classTheron_1_1DefaultAllocator.html" title="A simple general purpose memory allocator used by default. ">DefaultAllocator</a> respects aligned allocation requests, and allocates memory blocks whose start addresses are aligned to a boundary of a specified multiple of bytes, when requested. For example, when requested, it can allocate a block of memory starting at an address that is a multiple of 16 bytes.</p>
<p>Because this allocator supports alignment, it can be safely used by users needing to align their message types (using <a class="el" href="Align_8h_ac85c549d2873f38d3bfa43ab7926bf45.html#ac85c549d2873f38d3bfa43ab7926bf45">THERON_ALIGN_MESSAGE</a>).</p>
<p>The <a class="el" href="Defines_8h_ad51a5513a03bbbac961f4a559b2f6fcc.html#ad51a5513a03bbbac961f4a559b2f6fcc">THERON_ENABLE_DEFAULTALLOCATOR_CHECKS</a> define, defined in <a class="el" href="Defines_8h.html">Defines.h</a>, controls the enabling of various checking code, which is intended to be enabled only for debugging. It is defined to 1 by default in debug builds and to 0 in optimized (non-debug) builds.</p>
<p>The checks performed when <a class="el" href="Defines_8h_ad51a5513a03bbbac961f4a559b2f6fcc.html#ad51a5513a03bbbac961f4a559b2f6fcc">THERON_ENABLE_DEFAULTALLOCATOR_CHECKS</a> is enabled include:</p>
<ul>
<li>Guardband checking of allocated memory blocks.</li>
<li>Tracking of current and peak allocated memory (in bytes).</li>
<li>Detection and reporting of memory leaks on application exit via asserts.</li>
</ul>
<p>The checking of allocated memory, if enabled, is made thread-safe by means of an internal spin-lock, which unavoidably adds to the overhead of the checking. Generally the checking shouldn't be enabled in production code.</p>
<dl class="section note"><dt>Note</dt><dd>This default allocator can be replaced with a custom allocator implementation using <a class="el" href="classTheron_1_1AllocatorManager_a9ecdc8b1ae227f95a1eae7a2d399a9c0.html#a9ecdc8b1ae227f95a1eae7a2d399a9c0">AllocatorManager::SetAllocator</a>.</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classTheron_1_1AllocatorManager.html" title="Static class that manages allocators for use by Theron. ">AllocatorManager</a> </dd></dl>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.5
</small></address>
</body>
</html>
